package com.back.campus_back.service.impl;

import com.back.campus_back.domain.Admin;
import com.back.campus_back.domain.User;
import com.back.campus_back.mapper.AdminMapper;
import com.back.campus_back.service.AdminService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.time.temporal.TemporalAdjusters;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2021-04-17
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Autowired
    private RedisTemplate redisTemplate;



    //管理员登录
    public Admin login(String adminName, String adminPassword){

            QueryWrapper<Admin> wrapper = new QueryWrapper<>();
            wrapper.eq("admin_name", adminName);
            wrapper.eq("admin_password",adminPassword);
            Admin admin = adminMapper.selectOne(wrapper);
//            if (!(null == username) && !(null == password)) {
//                if (admin.getAdminName().equals(username) && admin.getAdminPassword().equals(password)) {
//
//                    System.out.println("登录成功！");
//                } else {
//                    System.out.println("登录失败！");
//                }
//            } else {
//                System.out.println("登录失败！");
//            }

            return admin;

    }

    public Admin findByName(String adminName){
        QueryWrapper<Admin> wrapper = new QueryWrapper<>();
        wrapper.eq("admin_name",adminName);
        Admin admin = adminMapper.selectOne(wrapper);
        return admin;
    }
}
